final static String employeeFileName = "employee.dat";
EmployeeFileAccessor efa;
void updateEmployeeDisplay(EmployeeList elist)
{
Employee emp = elist.first();
String textdata = "";
for (;;)
{
if (emp == null) break;
System.out.println("Appending " + emp.toString() + " to textarea");
textdata += emp.toString();
emp = elist.next();
}
ta.setText(textdata);
}
public EmployeeDataManager()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(new BorderLayout(0,0));
setBackground(java.awt.Color.lightGray);
setForeground(java.awt.Color.black);
setFont(new Font("Dialog", Font.PLAIN, 12));
setSize(751,309);
setVisible(false);
addPanel.setLayout(new GridBagLayout());
add("North", addPanel);
addPanel.setBounds(0,0,751,23);
label1.setText("Name:");
label1.setAlignment(java.awt.Label.RIGHT);
addPanel.add(label1, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.EAST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
label1.setBounds(39,0,51,23);
addPanel.add(nfield, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,2.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
nfield.setBounds(90,0,102,23);
label2.setText("Section#:");
label2.setAlignment(java.awt.Label.RIGHT);
addPanel.add(label2, new com.symantec.itools.awt.GridBagConstraintsD(2,0,1,1,1.0,1.0,java.awt.GridBagConstraints.EAST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
label2.setBounds(231,0,65,23);
addPanel.add(afield, new com.symantec.itools.awt.GridBagConstraintsD(3,0,1,1,1.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),0,0));
afield.setBounds(296,0,63,23);
label3.setText(" SSN:");
label3.setAlignment(java.awt.Label.RIGHT);
addPanel.add(label3, new com.symantec.itools.awt.GridBagConstraintsD(4,0,1,1,1.0,1.0,java.awt.GridBagConstraints.EAST,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
addPanel.add(sfield, new com.symantec.itools.awt.GridBagConstraintsD(5,0,1,1,2.0,1.0,java.awt.GridBagConstraints.WEST,java.awt.GridBagConstraints.HORIZONTAL,new Insets(0,0,0,0),30,0));
addPanel.add(addbutton, new com.symantec.itools.awt.GridBagConstraintsD(6,0,1,1,1.0,1.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(0,0,0,0),0,0));
addbutton.setBounds(695,0,35,23);
sortPanel.setLayout(new GridBagLayout());
add("Center", sortPanel);
sortPanel.setBounds(0,23,751,286);
choice.addItem("Name");
choice.addItem("Section");
choice.addItem("SSN");
try {
choice.select(0);
}
catch (IllegalArgumentException e) { }
sortPanel.add(choice, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,1.0,1.0,java.awt.GridBagConstraints.NORTH,java.awt.GridBagConstraints.HORIZONTAL,new Insets(30,10,0,0),0,0));
choice.setBackground(java.awt.Color.white);
choice.setBounds(10,30,129,25);
sortbutton.setLabel("Sort");
sortPanel.add(sortbutton, new com.symantec.itools.awt.GridBagConstraintsD(1,0,1,1,1.0,1.0,java.awt.GridBagConstraints.NORTH,java.awt.GridBagConstraints.NONE,new Insets(30,0,0,0),0,0));
sortPanel.add(ta, new com.symantec.itools.awt.GridBagConstraintsD(2,0,1,1,1.0,1.0,java.awt.GridBagConstraints.NORTH,java.awt.GridBagConstraints.BOTH,new Insets(30,0,40,15),0,0));
ta.setBounds(235,30,500,216);
setTitle("Employee Data Manager");
//}}
//{{INIT_MENUS
menu1.setLabel("File");
menu1.add(miExit);
miExit.setLabel("Exit");
mainMenuBar.add(menu1);
menu3.setLabel("Help");
menu3.add(miAbout);
miAbout.setLabel("About..");
mainMenuBar.add(menu3);
mainMenuBar.setHelpMenu(menu3);
//$$ mainMenuBar.move(4,277);
setMenuBar(mainMenuBar);
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
miAbout.addActionListener(lSymAction);
miExit.addActionListener(lSymAction);
addbutton.addActionListener(lSymAction);
sortbutton.addActionListener(lSymAction);
//}}
System.out.println("Opening file");
try
{
efa = new EmployeeFileAccessor(employeeFileName);
System.out.println("File opened");
}
catch (IOException e)
{
System.out.println("Unable to open file " + employeeFileName);
return;
}
// Fetch all employees from file, and display them in the text area